home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / SDIR24C.ASM < prev    next >
Assembly Source File  |  1984-02-07  |  47KB  |  930 lines

  1.     TITLE   SDIR - SORTED DIRECTORY COMMAND, Version 2.4
  2.     PAGE    64,132                            ; JAN 1983
  3. COMMENT |
  4.     SDIR [d:][path][filename[.ext]] [options]                           2.4
  5.      [filespec] same as for DIR command
  6.  
  7.      [options] * /A - List hidden files.
  8.                * /E - Without screen erase.
  9.                * /P - Pause when screen full.
  10.                  /X - Sort by extension.
  11.                  /S - Sort by size.
  12.                  /D - Sort by date/time.
  13.                  /N - Do not sort, original order.
  14.  
  15.        Default = *.* sorted by name.ext with screen erase.
  16.        * - Option may be combined with other options.
  17.  
  18.    This source file was created from an object file obtained
  19.  from Gene Plantz's BBS in Chicago. The original file name
  20.  was SD.HEX.  I then used DEBUG and CAPTURE to get the first
  21.  dis-assembly which  was then edited with WORDSTAR to create
  22.  a source that when assembled using MASM would duplicate the
  23.  original object file.
  24.    Comments have been added and I do hope they are helpful.
  25.  I have made several modifications to the first version and
  26.  am continuing to add comments.  This source file is an
  27.  excellent example for anyone wishing to learn 8086/8088
  28.  assembly language.  Use at your own risk and feel free to
  29.  share this file with your friends.
  30.    I certainly wish that John Chapman would publish his
  31.  source file.  His comments are sure to be more meaningful
  32.  than mine could ever be.  Some of the conversion routines
  33.  are very elegant, but difficult to understand.  As far as
  34.  I'm concerned, PRINTDD is magic.
  35.    Several modifications have been made.  They are:
  36.  
  37.         1. Filespecs are processed like DIR does.
  38.         2. No sort option was added. /N
  39.         3. Pause when screen full option added. /P
  40.     4. Number of files found is printed.
  41.  
  42.                                     Ted Reuss
  43.                                     Houston, TX
  44.  
  45.     SDIR Version 2.2  The GETFREE Subroutine was updated for DOS 2.0
  46.     April 1, 1983   by   Jack Y. Fong
  47.     Changes are denoted by "JYF" at the end of changed lines.
  48.  
  49.  
  50.         SDIR Version 2.3:
  51.         Added display of current directory name and volume name
  52.                 in header lines for DOS Release 2.0.
  53.         Added total of file sizes for the displayed files.
  54.                 This is helpful in DOS 2.0 since it allows you to determine
  55.                 the number of bytes used by all the files in a root or
  56.                 subdirectory (or used by a specified subset of
  57.                 the files in a root or subdirectory).
  58.  
  59.         John F. Ratti   29 June, 1983
  60.         Changes are denoted by "2.3" at the end of the changed lines.
  61.  
  62.         SDIR Version 2.4:
  63.         Added display of attribute byte. The column 'ATR' will display
  64.                 up to 4 attribute codes. The codes are as follows:
  65.                 A - Archive bit is off (file has been archived)
  66.                 H - Hidden bit is on (file is hidden)
  67.                 R - Read-only bit is on (file is read-only)
  68.                 S - System bit is on (file is a system file)
  69.         Corrected display of hidden, system, read-only and directory
  70.                 entries when /a option is specified.
  71.         Added pathname capability. Any pathname that DIR will accept
  72.                 will work. The code should have been rewritten, rather than
  73.                 modified. The resulting code is somewhat obtuse, and I
  74.                 apologize for it. I plan to write a proper pathname
  75.                 parser. When I do, I'll incorporate it into SDIR.
  76.         This version MUST be used under MS-DOS release 2.0.
  77.         John F. Ratti   03 July, 1983
  78.         Changes are denoted by "2.4" at the end of the changed lines.
  79. |
  80.  
  81.     SUBTTL  EQUATES & STRUCTURES
  82.     PAGE
  83. IF1
  84. DOSCALL MACRO       FUNC,PARM1
  85. .xcref
  86. F_C =       FUNC
  87. IFNB <PARM1>
  88. IF F_C EQ 2 OR (F_C GE 4 AND F_C LE 6) OR F_C EQ 14 OR F_C EQ 46
  89.     MOV     DL,PARM1
  90. ELSE
  91.     MOV     DX,OFFSET PARM1
  92. ENDIF
  93. ENDIF
  94.         MOV     AH,FUNC
  95.         INT     21H
  96. .cref
  97.         ENDM
  98. ENDIF
  99. .SALL   ;supress all macro expansions
  100. ;       PC-DOS INTERRUPT 21H FUNCTION CODES
  101. ;
  102. @CHROUT EQU     2       ;display char in DL
  103. @KEYIN  EQU     8       ;kybd input w/o echo
  104. @STROUT EQU     9       ;print string terminated with $
  105. @CKEYIN EQU     12      ;clr kybd bufr & do inp.func in AL
  106. @OPEN   EQU     15      ;open XFCB                                      2.4
  107. @SRCH1  EQU     17      ;search for first dir entry
  108. @SRCH2  EQU     18      ;search for next dir entry
  109. @GETDSK EQU     25      ;get default disk drive
  110. @SETDTA EQU     26      ;set disk transfer addr
  111. @FATAD2 EQU     28      ;get FAT of drive # in DL
  112. @PARSEF EQU     41      ;parse filename
  113. @GETDTE EQU     42      ;get system date
  114. @GETTME EQU     44      ;get system time
  115. @GETVER EQU     30H     ;get version number                             JYF
  116. @CTLBRK EQU     33H     ;get/set ctrl/break checking                    2.4
  117. @DSKFSP EQU     36H     ;get disk free space                            JYF
  118. @CHDIR  EQU     3BH     ;change directory                               2.4
  119. @CHMOD  EQU     43H     ;change/get file mode                           2.4
  120. @GETCD  EQU     47H     ;get current directory                          2.3
  121. @FIND1  EQU     4EH     ;find first dir. entry (DOS 2.0)                2.4
  122. @FIND2  EQU     4FH     ;find next dir entry (DOS 2.0)                  2.4
  123.  
  124. CR  EQU     0DH     ;carriage return
  125. LF  EQU     0AH     ;line feed
  126. FCB_1       EQU     5CH     ;fcb for parameter 1
  127. PARAM_L EQU 80H     ;# characters in PARAM_B
  128. PARAM_B EQU 81H     ;DOS cmd parameter buffer.
  129.  
  130. ; PC-DOS packed date   <yyyyyyym mmmddddd>
  131. P_DTE       RECORD  P_YR:7,P_MO:4,P_DY:5
  132. ; PC-DOS packed time   <hhhhhmmm mmmsssss>
  133. P_TME       RECORD  P_HR:5,P_MI:6,P_2S:5
  134.  
  135. DIR      RECORD  P_YR:7,P_MO:4,P_DY:5
  136. ; PC-DOS packed time   <hhhhhmmm mmmsssss>
  137. P_TME       RECORD  P_HR:5,P_MI:6,P_2S:5
  138.  
  139. DIRNTRY STRUC               ;directory entry structure
  140. LNK DW      0       ;ptr to next entry
  141. NAM DB      8 DUP(0),'.' ;filename
  142. EXT DB      3 DUP(0) ;extension
  143. TME DW      0       ;time
  144. DTE     DW      0       ;date
  145. SZL     DW      0       ;low word of size
  146. SZH     DW      0       ;high word of size
  147. ATR     DB      0       ;attribute byte                                 2.4
  148. DIRNTRY ENDS
  149.  
  150.         SUBTTL  DATA AREA & INITIALIZATION
  151.         PAGE
  152. SDIR    SEGMENT PUBLIC 'CODE'
  153.         ASSUME  CS:SDIR,DS:SDIR,ES:SDIR
  154.         ORG     100H
  155. MAIN    PROC    FAR
  156.         JMP     STARTS
  157.  
  158. DIRLNK  DW      DIRBUF  ;ptr to next opening in DIRBUF
  159. C1LNK   DW      0       ;ptr to row 1, column 1
  160. C2LNK   DW      0       ;ptr to row 1, column 2
  161. NBRFILS DW      0       ;# of files or detail lines
  162. SRTFLG  DB      0       ;if = 0 then sort else no sort
  163. CLSFLG      DB      0       ;if = 0 then clear screen
  164. EXTFLG      DB      0       ;if <> 0 then sort by ext
  165. SIZFLG      DB      0       ;if <> 0 then sort by size
  166. DTEFLG      DB      0       ;if <> 0 then sort by date/time
  167. PSEFLG      DB      0       ;if <> 0 then pause if screen full
  168. LPERSCR EQU 25      ;Lines per screen
  169. LINCNT      DB      LPERSCR-5 ;Number of lines left
  170. PSEMSG      DB      'Strike a key when ready . . . $'
  171.  
  172. HDNG1       DB      'SDIR: Sorted DIRectory listing, Version 2.4  ';   2.3
  173.             DB      'Volume '            ;                             2.3
  174. VOLNAME     DB      '             ' ;                                  2.3
  175. D_MM        DW      '00'            ;Month
  176.     DB      '/'
  177. D_DD        DW      '00'            ;Day
  178.     DB      '/'
  179. D_YY        DW      '00'            ;Year
  180.     DB      ' '
  181. T_HH        DW      '00'            ;Hours
  182.     DB      ':'
  183. T_MM        DW      '00'            ;Minutes
  184.             DB      CR,LF,'$'       ;                                  2.3
  185. HDNG2       DB      32 DUP(' ')     ;                                  2.3
  186.             DB      'Directory of ' ;                                  2.3
  187. HDRVE       DB      '@:'            ;                                  2.3
  188. DIRNAME     DB      '\',69 DUP(0)       ; directory name